/*
	menu screen
*/
#include <hge.h>
#include <hgesprite.h>
#include <hgefont.h>
#include "winsplash.h"
#include "menu.h"
#include "play.h"

hgeFont *w_text;

HEFFECT w_snd;



bool Winsplash_Init()
{
	bgtex=hge->Texture_Load("resources/images/background.png");
	w_snd=hge->Effect_Load("resources/sounds/stillalive.mp3");
	w_text=new hgeFont("resources/fonts/title.fnt");
	if (!bgtex|!w_text) return false;

	bgspr=new hgeSprite(bgtex,0,0,800,600);
	bgspr->SetBlendMode(BLEND_COLORMUL| BLEND_ALPHABLEND | BLEND_NOZWRITE);
	bgspr->SetColor(0xFFDDDDDD);

	hge->Effect_PlayEx(w_snd, 75, 0, 1.0, true);

	return true;
}

bool Winsplash_Clean()
{
	delete bgspr;
	hge->Effect_Free(w_snd);
	hge->Texture_Free(bgtex);
	delete w_text;
	return true;
}

bool Winsplash_Frame()
{

	if ((hge->Input_KeyDown(HGEK_S))){
		hge->Effect_Play(w_snd);
		Winsplash_Clean();
		Menu_Init();
		hge->System_SetState(HGE_FRAMEFUNC, Menu_Frame);
		hge->System_SetState(HGE_RENDERFUNC, Menu_Render);
		return false;
	}
	if ((hge->Input_KeyDown(HGEK_E))){
		hge->Effect_Play(w_snd);
		Winsplash_Clean();
		return true;
	}

	return false;
}

bool Winsplash_Render()
{
	hge->Gfx_BeginScene();
	hge->Gfx_Clear(0);
	bgspr->Render(0,0);
	w_text->printf(105, 250, HGETEXT_LEFT, "YOU WIN!\n\nHit [S] to start over\n or [E] to exit game\n");
	hge->Gfx_EndScene();

	return false;
}
